package yl.hs.bmipfull.controllers.construction;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.system.IActiveService;
import yl.hs.bmipfull.utils.datastate.ActiveDeviceType;
import yl.hs.bmipfull.viewmodels.WebResult;

import java.util.HashMap;

/*
 * ConstructionMainController
 * @category
 * @author 谢景广
 * @date 2022-05-25
 */
@RequestMapping("/construction")
@Api(value = "工地系统", tags = "工地系统——系统信息获取")
@RestController
public class ConstructionMainController extends ControllerBase {

    @Autowired
    IActiveService activeService;

    @ApiOperation(value = "获取工地端系统激活信息", notes = "获取工地端系统激活信息")
    @RequestMapping(value = "/checkActive", method = RequestMethod.GET)
    public WebResult checkActiveInfo(){
        try {
            var day = activeService.getAvailableDays(ActiveDeviceType.Construction);
            var dataMap = new HashMap<String, Object>();
            dataMap.put("available_days",day);
            return success("ok", dataMap);
        }
        catch (Exception ee){
            return error(ee);
        }
    }
}
